//
//  FDAboutController.m
//  FamousDoctorOnline
//
//  Created by wszyxc on 16/7/5.
//  Copyright © 2016年 wszyxc. All rights reserved.
//

#import "FDAboutController.h"
#import "Masonry.h"
#import "SVProgressHUD.h"

@interface FDAboutController ()

@property (nonatomic,strong)UIView *backGroudView;
//点击用户协议的按钮
@property (nonatomic,strong)UIButton *clickBtn;
//App图标
@property (nonatomic , weak)UIImageView *productLogoImageView;
//快医文字图片框
@property (nonatomic , weak)UIImageView *productTextImageView;
//用户协议按钮
@property (nonatomic , weak)UIButton *userinfoButton;
//用户协议图标
@property (nonatomic , weak)UIImageView *agreementImageView;
//尖角按钮
@property (nonatomic , weak)UIButton *inputButton;
//版本号文本框
@property (nonatomic , weak)UILabel *versionLabel;
//用户交流群文本框
@property (nonatomic , weak)UILabel *userGroupLabel;
//线条
@property (nonatomic , weak)UIView *lineView;

@end

@implementation FDAboutController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];

    [self setLayout];
}

/**创建UI*/
- (void)setupUI {
    //App图标
    UIImageView *productLogoImageView = [[UIImageView alloc]init];
    self.productLogoImageView = productLogoImageView;
    productLogoImageView.image = [UIImage imageNamed:@"product_img_logo_nor.png"];
    [self.view addSubview:productLogoImageView];
    
    //快医文字图片框
    UIImageView *productTextImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"product_text_logo_nor.png"]];
    self.productTextImageView = productTextImageView;
    [self.view addSubview:self.productTextImageView];
    
    //用户协议图标
    UIImageView *agreementImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"product_img_icon_xieyi.png"]];
    self.agreementImageView = agreementImageView;
    [self.view addSubview:agreementImageView];
    
    //用户协议按钮
    UIButton *userinfoButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.userinfoButton = userinfoButton;
    [userinfoButton setTitle:@"用户协议" forState:UIControlStateNormal];
    [userinfoButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self.view addSubview:userinfoButton];
    
    //点击用户协议的按钮
    self.clickBtn=[[UIButton alloc]init];
    [self.clickBtn addTarget:self action:@selector(clickChoose) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:self.clickBtn];
    
    //尖角按钮
    UIButton *inputButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.inputButton = inputButton;
    [inputButton setImage:[UIImage imageNamed:@"product_button_input_jianjiao.png"] forState:UIControlStateNormal];
    [self.view addSubview:inputButton];
    
    //版本号文本框
    UILabel *versionLabel = [[UILabel alloc]init];
    self.versionLabel = versionLabel;
    versionLabel.textColor = [UIColor colorWithRed:62/255.0 green:172/255.0 blue:234/255.0 alpha:1];
    versionLabel.text = @"version: 1.4.0";
    [self.view addSubview:versionLabel];
    
    //用户交流群文本框
    UILabel *userGroupLabel = [[UILabel alloc]init];
    self.userGroupLabel = userGroupLabel;
    //通过系统自带的数码测色计取参数
    userGroupLabel.textColor = [UIColor colorWithRed:62/255.0 green:172/255.0 blue:234/255.0 alpha:1];
    userGroupLabel.text = @"用户交流群: 4638375473";
    [self.view addSubview:userGroupLabel];
    
    UIView *lineView = [[UIView alloc]init];
    self.lineView = lineView;
    lineView.backgroundColor = [UIColor colorWithRed:240/255.0 green:240/255.0 blue:240/255.0 alpha:1];
    [self.view addSubview:lineView];
}

//点击弹框
-(void)clickChoose{
    
   [SVProgressHUD showSuccessWithStatus:@"用户协议"];
    //增加黑色的view
    self.backGroudView=[[UIView alloc]init];
    self.backGroudView.frame=CGRectMake(0, 0, self.view.size.width, self.view.size.height);
    self.backGroudView.backgroundColor=[UIColor blackColor];
    self.backGroudView.alpha=0.6;
    [self.view addSubview:self.backGroudView];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [SVProgressHUD dismissWithDelay:0];
        [self.backGroudView removeFromSuperview];
    });

}

/**设置控件约束*/
- (void)setLayout
{
    //App图标约束
    [self.productLogoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.offset(100);
        make.size.mas_equalTo(CGSizeMake(67, 88));
    }];
    
    //快医文字图片框约束
    [self.productTextImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.productLogoImageView.mas_centerX);
        make.top.equalTo(self.productLogoImageView.mas_bottom);
    }];
    
    //协议图标约束
    [self.agreementImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(20);
        make.size.mas_equalTo(CGSizeMake(14, 15));
        make.top.equalTo(self.productTextImageView.mas_bottom).offset(50);
    }];
    
    //用户协议约束
    [self.userinfoButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.agreementImageView.mas_right).offset(20);
        make.centerY.equalTo(self.agreementImageView.mas_centerY);
    }];
    
    //尖角按钮约束
    [self.inputButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-20);
        make.centerY.equalTo(self.userinfoButton.mas_centerY);
    }];
    
    //版本号文本框约束
    [self.versionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(-50);
        make.centerX.equalTo(self.view.mas_centerX);
    }];
    
     //用户交流群文本框约束
    [self.userGroupLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.versionLabel.mas_top).offset(-20);
        make.centerX.equalTo(self.view.mas_centerX);
    }];
    
    //lineView约束
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(1);
        make.left.mas_equalTo(self.userinfoButton.mas_left);
        make.right.offset(0);
        make.top.equalTo(self.userinfoButton.mas_bottom).offset(10);
    }];
    //点击按钮的约束
    [self.clickBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(self.userinfoButton.mas_height).offset(0);
        make.left.mas_equalTo(self.userinfoButton.mas_left);
        make.right.offset(0);
        make.bottom.equalTo(self.userinfoButton.mas_bottom).offset(0);
    }];
}

@end
